<script type="text/javascript">
    $(function(){
        try {
            $("#progress").show();
            $.ajax({
                type: "POST",
                url : "../controllers/ClasseController.php",
                data : {
                    acao : 'listar',
                    tipo_listagem : 'arvore'
                },
                success: function(msg){
                    try {
                        if (msg.indexOf("Exception: ") != -1) {
                            msg = msg.replace("Exception: ", "");
                            showMessage(ERROR_MESSAGE, msg);
                            return;
                        }
                        $("#arvore_classes").html(msg);
                        $("#principal_content_title").html("Thesaurus");
                        $('#thesaurus #nome').editable( '../controllers/ClasseController.php', {
                            "callback": function( sValue, y ) {
                                if (sValue.indexOf("Exception: ") != -1) {
                                    sValue = sValue.replace("Exception: ", "");
                                    showMessage(ERROR_MESSAGE, sValue);
                                    return;
                                }
                                if (sValue.indexOf("Exception: ") != -1) {
                                    var message = sValue.replace("Exception: ", "");
                                    message = message.substring(0, message.indexOf("|"));
                                    showMessage(ERROR_MESSAGE, message);
                                    sValue = sValue.substring(sValue.indexOf("|") + 1, sValue.length);
                                }
                            },
                            "submitdata": function ( value, settings ) {
                                return { "row_id": this.parentNode.getAttribute('id'), "acao" : "alterar" };
                            },
                            "height": "25px"
                        } );
                        $("#thesaurus").treeview({
                            animated: "slow",
                            collapsed: true,
                            unique: true
                        });
                        $('.botao').button();
                        $('.botao').click(function () {
                            $('#cod_pai_cadastrar').val("");
                            showDialogManutencaoRecurso(false, 450, 235, "forms/classe.html", {
                                Cadastrar : function () {
                                    manutencaoClasse('cadastrar', null);
                                },
                                Cancelar: function() {
                                    $(this).dialog('close');
                                }
                            });
                        });
                        verificarPermissao('classe', 'botao_cadastrar', 'inclusao');
                        $('#thesaurus').parent().show();
                        $('.botao').show();
                        $("#progress").hide();
                    } catch(e) {
                        reportCrash(null, e.name, e.stack);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $("#progress").hide();
                    reportCrash(XMLHttpRequest, textStatus, errorThrown);
                }
            });
        } catch(e) {
            reportCrash(null, e.name, e.stack);
        }
    });
</script>
<br/>
<div id="arvore_classes">
</div>
<button class="botao" style="display: none;" id="botao_cadastrar">Incluir Novo</button>